import React, { Component } from 'react';

import api from '../../../api/api';
import { Modal, Button, message} from 'antd';
import './index.scss';
class HisOrder extends Component {
  constructor(props) {
    super(props);
    this.state = {
      loading: false,
      visible: false,
    };
  }
  handleOk = async () => {
    try {
      this.setState({ loading: true });
      const removeOrder = await api.revokeSaleOrder(this.props.orderId);
      this.setState({ loading: false, visible: false });
      message.success('撤单成功！');
      this.props.parent.getChildrenMsg(this, false)
    } catch (e) {
        message.error(e.message);
    }

    // this.props.revokeSaleOrder(formValues,true);

  }
  handleCancel = () => {
    this.props.parent.getChildrenMsg(this, false)
    this.setState({ visible: false });
  }
  componentWillMount() {
    // this.searchData();
  }
  render() {
    const { visible, loading } = this.state;
    return (
      <div>
        <Modal
          visible={this.props.revokeModalShow}
          title="撤单确认"
          onOk={this.handleOk}
          onCancel={this.handleCancel}
          footer={[
            <Button key="submit" type="primary" size="large" loading={loading} onClick={this.handleOk}>
              确定
            </Button>,
            <Button key="back" size="large" onClick={this.handleCancel}>取消</Button>,
          ]}
        >
          <div>确认撤销订单？</div>
          <div>订单号：{this.props.orderNo}</div>
          <div>购买人：{this.props.purchaser}</div>
        </Modal>
      </div>
    );
  }
}

export default HisOrder;
